<template>
  <view class="search-container">
   
    <van-search
      placeholder="请输入搜索关键词"
      @focus="cc"
      :show-action="isEcunt"
      @search="onSearch"
      @cancel="onCancel"
    />
   
     <!-- 学科列表 -->
  <view class="search-body">
      <view class="empty" v-if="course.length == 0">
      <text class="title">暂无内容哦~</text>
    </view> 
    <list :list="course"></list>

  </view>
  </view>
</template>


<script>
import list from '../comopnents/list'
import request from "../utils/util";
export default {
  components:{
    list
  },
  data() {
    return {
      course:[],
      isEcunt: false,
    };
  },
  methods: {
    async onSearch(e) {
     console.log(e.detail)
      const res = await request({
        url: "course/search",
        data: {
          name: e.detail
        },
      });
      console.log(res)
      this.course=res.data.message
    },
    onCancel() {
      this.isEcunt = false;
    },
    cc() {
      this.isEcunt = true;
    },
  },
};
</script>


<style lang="less">
.search-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.search-head {
  padding: 30rpx 0;
  background-color: #fff;
  display: flex;
}

.search-input {
  margin-left: 30rpx;
  margin-right: 30rpx;
  padding-left: 55rpx;
  width: 100%;
  height: 74rpx;
  background: rgba(243, 243, 243, 1);
  opacity: 1;
  border-radius: 8px;
  font-size: 14px;
  flex: 1;
}

.icon-search {
  position: absolute;
  left: 40rpx;
  top: 48rpx;
  width: 56rpx;
  height: 56rpx;
  color: #a8a8a8;
}

.search-button {
  margin-right: 30rpx;
  width: 100rpx;
  height: 74rpx;
  line-height: 74rpx;
  text-align: center;
  color: #ff951c;
}

.search-body {
  display: flex;
  flex-wrap: wrap;
  padding-bottom: 32rpx;
  height: 100%;
}

.empty {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 600rpx;
}

.empty .title {
  font-size: 14px;
  color: gray;
}
</style>